package naga.x.db.support;

import java.sql.SQLException;
import java.util.Properties;

import javax.sql.DataSource;

import org.apache.ibatis.datasource.DataSourceException;
import org.apache.ibatis.datasource.DataSourceFactory;

import com.alibaba.druid.pool.DruidDataSource;

public class DruidDataSourceFactory implements DataSourceFactory {

	private DruidDataSource dataSource;
	
	public DruidDataSourceFactory() {
		this.dataSource = new DruidDataSource();
	}

	@Override
	public void setProperties(Properties props) {
		try {
			com.alibaba.druid.pool.DruidDataSourceFactory.config(dataSource, props);
		} catch (SQLException e) {
			throw new DataSourceException(e);
		}
	}

	@Override
	public DataSource getDataSource() {
		return dataSource;
	}

}
